<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .seckill div{
            float:left;
            width: 40px;
            height: 40px;
            margin-right: 5px;
            background-color: #000;
            color: #fff;
            text-align: center;
            line-height: 40px;
        }
    </style>
</head>
<body>
    <div class="seckill">
        <div class='h'>
            <span>00</span>
        </div>
        <div class='m'>
            <span>01</span>
        </div>
        <div class='s'>
            <span>01</span>
        </div>
    </div>
</body>
<script>
    //获取元素
    var h = document.querySelector('.seckill .h span');
    var m = document.querySelector('.seckill .m span');
    var s = document.querySelector('.seckill .s span');

    //注册事件
    timeID = setInterval(function(){
        var hh = parseInt(h.innerText)
        var mm = parseInt(m.innerText)
        var ss = parseInt(s.innerText)
        if(hh == 0 && mm == 0 && ss == 0){
            clearInterval(timeID);
            return
        }
        ss--;
        if(ss < 0) {
            mm--;
            if(mm < 0) {
                hh--;
                mm = 59;
            }
            ss = 59;
        }
        hh = hh < 10? '0'+hh : hh;
        mm = mm < 10? '0'+mm : mm;
        ss = ss < 10? '0'+ss : ss;
        h.innerText = hh
        m.innerText = mm
        s.innerText = ss
    },1000)
</script>
<!-- <script src='../jquery-1.12.4.js'></script> -->
<script>
    // $(function(){
    //     timeID = setInterval(function(){
    //         var s = parseInt($('.seckill .s span').text())
    //         var m = parseInt($('.seckill .m span').text())
    //         var h = parseInt($('.seckill .h span').text())
    //         if(h == 0 && m == 0 && s == 0) {
    //             clearInterval(timeID)
    //             return
    //         }
    //         s--;
    //         if(s < 0){
    //             m--
    //             if(m < 0){
    //                 h--
                    
    //                 m = 59
    //             }
    //             s = 59;
    //         }
    //         s=s < 10? '0'+s:s
    //         m=m < 10? '0'+m:m
    //         h=h < 10? '0'+h:h
    //         $('.seckill .s span').text(s)
    //         $('.seckill .m span').text(m)
    //         $('.seckill .h span').text(h)
    //     },1000)
    // })
</script>
</html>